using System;
using System.Collections.Generic;
using System.Linq;

namespace SpecMaker.UnitTests.SupportClasses
{
    public class BankAccount
    {
        private List<BankTransaction> _transactions = new List<BankTransaction>( );

        public List<BankTransaction> Transactions
        {
            get { return _transactions; }
        }

        public decimal Total
        {
            get
            {
                
                var total =  _transactions.Sum(x => x.Amount);
                if(total < 0.00m)
                    throw new AccountException();
                return total;
            }
        }

        public void AddTrans(BankTransaction transaction)
        {
             if(transaction.Amount - Total > 0)
                 throw new OverDraftException("Over Draft");
            _transactions.Add(transaction);
        }
    }

    public class OverDraftException : Exception
    {
        public OverDraftException(string s)
        {
            
        }
    }
}